package com.dllo.lanou.cookapp.fragment;

import android.support.v4.app.Fragment;
import android.util.SparseArray;




/**
 * Created by dllo on 15/10/21.
 */
public class FragmentFactory {

    private static SparseArray<Fragment> fragmentMap = new SparseArray<>();

    public static Fragment createFragment(int position) {
        Fragment f = fragmentMap.get(position);
        if (f == null) {
            switch (position) {
                case 0:
                    f = new HomePagerFragment();

                    break;

                case 1:
                    f = new ClassifyFragment();
                    break;

                default:
                    f = new ShowCookingFragment();
                    break;

            }
            fragmentMap.put(position, f);

        }
        return f;

    }



}
